package com.fjwt.gz.mgr.ctrl.sysuser;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fjwt.gz.core.model.ApiRes;
import com.fjwt.gz.db.dto.SysScheduledLogDTO;
import com.fjwt.gz.db.entity.SysScheduledLogEntity;
import com.fjwt.gz.mgr.ctrl.CommonCtrl;
import com.fjwt.gz.service.impl.SysScheduledLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 系统定时任务执行日志
 *
 * @author mei
 */
@Slf4j
@RestController
@RequestMapping("/api/sysScheduledLog")
public class SysScheduledLogController extends CommonCtrl {

    @Autowired
    SysScheduledLogService sysScheduledLogService;

    @PreAuthorize("hasAnyAuthority('ENT_SYS_JOB')")
    @GetMapping
    public ApiRes getSysScheduledLogList() {
        SysScheduledLogDTO scheduledLogDTO = getObject(SysScheduledLogDTO.class);
        log.info("机构端查询定时任务执行日志接口：/api/sysScheduledLog/list, 获取参数：{}", JSONUtil.toJsonStr(scheduledLogDTO));
        IPage iPage = sysScheduledLogService.getSysScheduledLogList(getIPage(true), scheduledLogDTO);
        log.info("机构端查询定时任务执行日志接口：/api/sysScheduledLog/list, 返回结果：{}", JSONUtil.toJsonStr(iPage));
        return ApiRes.page(iPage);
    }


}
